package com.example.index.controller;

import com.example.index.entity.*;
import com.example.index.service.*;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class CourseInfoController {

    @Resource
    private CourseInfowhyService courseInfowhyService;
    @Resource
    private EmploymentService employmentService;
    @Resource
    private ProfessionService professionService;
    @Resource
    private CourseinfoStageService courseinfoStageService;

    @Resource
    private CourseSceneService courseSceneService;

    @GetMapping("photography")
    public String photography(Integer id,ModelMap modelMap) {
        Page<CourseInfowhy> courseInfoWes = courseInfowhyService.queryByPage(new CourseInfowhy(), PageRequest.of(0, 1000));
        List<CourseInfowhy> courseInfowhyList = courseInfoWes.getContent();
        modelMap.addAttribute("courseinfowhyList",courseInfowhyList);

        Employment employment = new Employment();
        employment.setProfessionId(id);
        List<Employment> employments = employmentService.queryALL(employment);
        modelMap.addAttribute("employment",employments);
        Profession profession = professionService.queryById(id);
        modelMap.addAttribute("profession",profession);

        Page<CourseinfoStage> courseStages = courseinfoStageService.queryByPage(new CourseinfoStage(), PageRequest.of(0, 1000));
        List<CourseinfoStage> courseStageList = courseStages.getContent();
        modelMap.addAttribute("courseStageList",courseStageList);


        CourseScene courseScene = new CourseScene();
        courseScene.setStatus(1);
        Page<CourseScene> courseScenes = courseSceneService.queryByPage(courseScene, PageRequest.of(0, 1000));
        List<CourseScene> courseSceneList = courseScenes.getContent();
        modelMap.addAttribute("courseSceneList", courseSceneList);

        courseScene.setStatus(0);
        Page<CourseScene> course= courseSceneService.queryByPage(courseScene, PageRequest.of(0, 1000));
        List<CourseScene> courseList = course.getContent();
        modelMap.addAttribute("courseList", courseList);
        return "photography";
    }



}
